﻿Imports System.Data.OleDb
Public Class Matches
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub AddMatch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles AddMatch.Click


        Dim conn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("PlayersConnectionString").ConnectionString)
        Dim sql As String = "Insert into Matches (HomeTeam,AwayTeam,Venue,MatchDate,MatchTime,AddedBy,AddedDate) Values (@f1,@f2,@f3,@f4,@f5,@f6,Now())"
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        cmd.CommandType = CommandType.Text

        cmd.Parameters.AddWithValue("@f1", tb_hometeam.Text)
        cmd.Parameters.AddWithValue("@f2", tb_awayteam.Text)
        cmd.Parameters.AddWithValue("@f3", tb_matchvenue.Text)
        cmd.Parameters.AddWithValue("@f4", tb_matchdate.Text)
        cmd.Parameters.AddWithValue("@f5", tb_matchtime.Text)
        cmd.Parameters.AddWithValue("@f6", User.Identity.Name)

        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        cmd.Dispose()
        conn.Dispose()
        Response.Redirect("MatchesDate.aspx")
    End Sub
End Class